import time
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

# 打开浏览器
driver = webdriver.Chrome()
driver.maximize_window()

# 请求百度
driver.get('https://www.baidu.com/')

# 定位搜索框,输入天气预报
kw = driver.find_element(By.ID, 'kw')
kw.send_keys('天气预报')

# 复制全选输入内容
time.sleep(3)
kw.send_keys(Keys.CONTROL, 'a')
kw.send_keys(Keys.CONTROL, 'c')

# 请求so
time.sleep(3)
driver.get('https://www.so.com/')

# 定位搜索框
input1 = driver.find_element(By.ID, 'input')

# 粘贴
input1.send_keys(Keys.CONTROL, 'v')

# 点击搜索按钮
driver.find_element(By.ID, 'search-button').click()

# 退出浏览器
driver.quit()
